import featureAbility from '@ohos.ability.featureAbility'
import preferences from '@ohos.data.preferences';
import router from '@system.router';
// 获取context并调用相关方法
let context = featureAbility.getContext();
//轻量级数据库
let storagePromise = preferences.getPreferences(context, 'mystore');
export default {
    onCreate() {
        storagePromise.then((preferences) => {
            let getPromise = preferences.get('token', 'default');
            getPromise.then((value) => {
                console.info("CHWxxx---The value of 'startup' is " + value);
                if(value!= "default"){
                    router.push({
                        uri:"pages/home/home"
                    })
                }
            }).catch((err) => {
                console.info("CHWxxx---Failed to get the value of 'startup'. Cause: " + err);
            })
        }).catch((err) => {
            console.info("CHWxxx---Failed to get preferences.")
        });
        console.info("xxx---Application onCreate");

    },
    onDestroy() {
        console.info("Application onDestroy");
    },

};
